//专门用来存放关于搜索的所有接口
const Router = require('koa-router'); //引入路由
const search = new Router();
const db = require('../utils/db');
//写对应的接口

search.post('/',async ctx=>{
    const name = ctx.request.body.name;
    let data = await new Promise((reslove,reject) => {
        return db.query(`select * from book_class where book_name="${name}"`,(err,data) => {
            if(err) console.log(err);
            reslove(data);
            })
        })
        ctx.body = {
            status:200,
            data:data
        }
    })



module.exports = search;